﻿using System.Diagnostics;
using static System.Console;
namespace task2_character_game
{
    
    internal class Program
    {
        public static int num_x = 0;//水平方向画几个空格
        public static int num_y = 0;//竖直方向写几个换行
        public static void Main(string[] args)
        {
           
            Write("Hello,world!"); 
            WriteLine("按q退出游戏");
            while (true)
            {
                int chara = Read();
                if (chara == 'w')
                {
                    Clear();//删去原位置的字符串
                    num_y--;//读到w就少输出一个换行
                    for (int i = 0; i < num_y; i++)
                    {
                        WriteLine();
                    }

                    for (int i = 0; i <num_x; i++)
                    {
                        Write("   ");
                    }
                    Write("Hello,world!");//输出新位置的字符串
                }
                                            
                else if (chara == 's')
                {
                    Clear();
                    num_y++;//读到s就多输出一个换行
                    for (int i = 0; i < num_y; i++)
                    {
                        WriteLine();
                    }

                    for (int i = 0; i < num_x; i++)
                    {
                        Write("   ");
                    }
                    Write("Hello,world!");
                }
                                            
                else if (chara == 'd')
                {
                    Clear();
                    num_x++;//读到d就多输出一个空格
                    for (int i = 0; i < num_y; i++)
                    {
                        WriteLine();
                    }
                    for (int i = 0; i < num_x; i++)
                    {
                        Write("   ");
                    }

                    
                    Write("Hello,world!");
                                  
                }
                else if (chara == 'a')
                {
                    Clear();
                    num_x--;//读到a就少输出一个空格
                    for (int i = 0; i < num_y; i++)
                    {
                        WriteLine();
                    }
                    for (int i = 0; i < num_x; i++)
                    {
                        Write("   ");
                    }
                    Write("Hello,world!");
                }
                else if(chara=='q')
                {
                    break;
                }
            }
        }
    }
    
}